Repository navigation
Conversation
When FileAudioSource needed more than one read to decide that a local MP4 is already optimized, only the last chunk reached the parser and the earlier probe bytes, including the ftyp atom, were dropped.
Unit tests check that FileAudioSource hands every probed byte to the parser, with two controls for the first-read and restructure paths. A player test plays a short AAC fixture whose moov atom starts beyond the first 64 KiB read to its end.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some local M4A files don't play at all: the player reports "The specified file type is not supported" and nothing starts. It happens with files that are already optimized for streaming, but whose header (the moov atom) begins after the first 64 KiB of the file, for example because a large free atom sits in front of it.
The cause is small. When the first chunk is not enough to tell whether the file is optimized,
FileAudioSourcereads on and keeps the chunks in a buffer. Once it knew the answer, it passed on only the last chunk and dropped the earlier ones, so the parser never saw the start of the file. Now it passes on the whole buffer. Files that are decided on the first read, and files that need restructuring, behave as before.The tests cover this layout and those two unchanged cases, and one test plays a 2 second file of this layout to its end. Without the fix the two new cases fail and the two others pass.
I don't know how common such files are. I ran into this while looking at playback problems in Amperfy. Besides the tests on macOS I played such a file from the cache on an iPhone in a private Amperfy build; I did not compare it there without the fix. The fixture is 91 KB, and I can add the script that generates it if you'd like.